package interfaces;

import java.util.List;

import javax.annotation.Resource;

import javax.ejb.SessionContext;
import javax.ejb.Stateless;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import modelo.Administrador;

@Stateless(name = "GestionarAdministrador", mappedName = "MiPrimerProyecto-Model-GestionarAdministrador")
public class GestionarAdministradorBean implements GestionarAdministradorR {
    @Resource
    SessionContext sessionContext;
    @PersistenceContext(unitName = "Model")
    private EntityManager em;

    public GestionarAdministradorBean() {
    }

    public Administrador persistAdministrador(Administrador administrador) {
        em.persist(administrador);
        return administrador;
    }

    public Administrador mergeAdministrador(Administrador administrador) {
        return em.merge(administrador);
    }

    public void removeAdministrador(Administrador administrador) {
        administrador = em.find(Administrador.class, administrador.getIdadmin());
        em.remove(administrador);
    }

    /** <code>select o from Administrador o</code> */
    public List<Administrador> getAdministradorFindAll() {
        return em.createNamedQuery("Administrador.findAll").getResultList();
    }
}
